package com.qc.entity;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

import com.qc.common.DateUtil;

public class OrderEntity extends BaseEntity {
	
	private long orderId;
	private long bossUserId;
	private long secretaryUserId;
	private String orderNumber;
	private String tag;
	private String startDate;
	private String endDate;
	private String shopMark;
	private String shopProvince;
	private String shopCity;
	private String shopDistrict;
	private String shopAddress;
	private double shopLatitude;
	private double shopLongitude;
	private long cuId;//用户优惠券 
	private int orderState;//订单状态 0:无状态，等待BOSS下单 1:待确认,BOSS申请，等待秘书接单 2:订单生效，秘书已经接单，但是开始时间未到 3:服务中，开始时间到了 4:结束
	private double money;//订单金额
	private int isPay;//是否支付 0/未支付；1/已支付
	private int isComment;//是否评价 0/未评价；1/已评价
	
	private String avatar;//秘书头像
	private String nickname;//秘书昵称
	private String bossAvatar;//boss头像
	private String bossNickname;//boss昵称
	
	private OrderBillEntity billEntity;
	private String gmtPayment;//支付时间
	
	private int payType;//支付方式 1/支付宝 2/微信 3/银联
	
	private int isCancel;//是否能取消，判断订单开始时间离当前时间是否在8小时以外，如果是 就返回1 说明取消，否则返回0，不能取消。
	
	private long orderNumberDays;//订单天数，由开始时间和结束时间计算
	
	private int cancelType;//用户区分短信发送，不做其他逻辑判断。1，未支付的时候，BOSS可以取消订单,2，支付了，未开始，8小时前可以取消订单,3，秘书拒绝接单
	
	//是否接单状态 0 不接单  1 接单
	private int ordersState;
	
	//订单完成 返回 双方是否接单状态
	// boss_user_id 返回接单状态
	private int bossOrdersState;
	//secretary_user_id 返回接单状态
	private int secretaryOrdersState;
	
	//距离时间多长  2天2小时
	private String timeDay;

	public static OrderEntity getInstance(ResultSet rs) throws SQLException {
		OrderEntity entity = new OrderEntity();
		
		entity.setOrderId(rs.getLong("order_id"));
		entity.setBossUserId(rs.getLong("boss_user_id"));
		entity.setSecretaryUserId(rs.getLong("secretary_user_id"));
		entity.setOrderNumber(rs.getString("order_number"));
		entity.setTag(rs.getString("tag"));
		entity.setStartDate(rs.getString("start_date"));
		entity.setEndDate(rs.getString("end_date"));
		entity.setShopMark(rs.getString("shop_mark"));
		entity.setShopProvince(rs.getString("shop_province"));
		entity.setShopCity(rs.getString("shop_city"));
		entity.setShopDistrict(rs.getString("shop_district"));
		entity.setShopAddress(rs.getString("shop_address"));
		entity.setShopLatitude(rs.getDouble("shop_latitude"));
		entity.setShopLongitude(rs.getDouble("shop_longitude"));
		entity.setCuId(rs.getLong("cu_id"));
		entity.setOrderState(rs.getInt("order_state"));
		entity.setMoney(rs.getDouble("money"));
		entity.setIsPay(rs.getInt("is_pay"));
		entity.setIsComment(rs.getInt("is_comment"));
		entity.setPayType(rs.getInt("pay_type"));
		
		try{
			entity.setTimeDay(rs.getString("time_day"));
		}catch(Exception e) {
		}
		
		entity.setIsCancel(DateUtil.getDatePoor(DateUtil.stringFormatDateTime2(entity.getStartDate()), new Date()) < 8 ? 0 : 1);
		try{
			entity.setOrderNumberDays(rs.getLong("order_days"));
		}catch(Exception e) {
		}
		try {
			entity.setAvatar(rs.getString("avatar"));
			entity.setNickname(rs.getString("nickname"));
		} catch (Exception e) {
		}

		try {
			entity.setOrdersState(rs.getInt("orders_state"));
		} catch (Exception e) {
		}
		
		try{
			entity.setOrderNumberDays(rs.getLong("order_days"));
		}catch(Exception e) {
		}
		
		return entity;
	}
	
	public long getOrderId() {
		return orderId;
	}
	public void setOrderId(long orderId) {
		this.orderId = orderId;
	}
	public long getBossUserId() {
		return bossUserId;
	}
	public void setBossUserId(long bossUserId) {
		this.bossUserId = bossUserId;
	}
	public long getSecretaryUserId() {
		return secretaryUserId;
	}
	public void setSecretaryUserId(long secretaryUserId) {
		this.secretaryUserId = secretaryUserId;
	}
	public String getOrderNumber() {
		return orderNumber;
	}
	public void setOrderNumber(String orderNumber) {
		this.orderNumber = orderNumber;
	}
	public String getTag() {
		return tag;
	}
	public void setTag(String tag) {
		this.tag = tag;
	}
	public String getStartDate() {
		return startDate;
	}
	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}
	public String getEndDate() {
		return endDate;
	}
	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}
	public String getShopMark() {
		return shopMark;
	}
	public void setShopMark(String shopMark) {
		this.shopMark = shopMark;
	}
	public String getShopProvince() {
		return shopProvince;
	}
	public void setShopProvince(String shopProvince) {
		this.shopProvince = shopProvince;
	}
	public String getShopCity() {
		return shopCity;
	}
	public void setShopCity(String shopCity) {
		this.shopCity = shopCity;
	}
	public String getShopDistrict() {
		return shopDistrict;
	}
	public void setShopDistrict(String shopDistrict) {
		this.shopDistrict = shopDistrict;
	}
	public String getShopAddress() {
		return shopAddress;
	}
	public void setShopAddress(String shopAddress) {
		this.shopAddress = shopAddress;
	}
	
	
	public double getShopLatitude() {
		return shopLatitude;
	}
	public void setShopLatitude(double shopLatitude) {
		this.shopLatitude = shopLatitude;
	}
	public double getShopLongitude() {
		return shopLongitude;
	}
	public void setShopLongitude(double shopLongitude) {
		this.shopLongitude = shopLongitude;
	}
	public long getCuId() {
		return cuId;
	}
	public void setCuId(long cuId) {
		this.cuId = cuId;
	}
	public int getOrderState() {
		return orderState;
	}
	public void setOrderState(int orderState) {
		this.orderState = orderState;
	}
	public double getMoney() {
		return money;
	}
	public void setMoney(double money) {
		this.money = money;
	}
	public int getIsPay() {
		return isPay;
	}
	public void setIsPay(int isPay) {
		this.isPay = isPay;
	}

	public String getAvatar() {
		return avatar;
	}

	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public int getIsComment() {
		return isComment;
	}

	public void setIsComment(int isComment) {
		this.isComment = isComment;
	}

	public OrderBillEntity getBillEntity() {
		return billEntity;
	}

	public void setBillEntity(OrderBillEntity billEntity) {
		this.billEntity = billEntity;
	}

	public String getGmtPayment() {
		return gmtPayment;
	}

	public void setGmtPayment(String gmtPayment) {
		this.gmtPayment = gmtPayment;
	}

	public int getPayType() {
		return payType;
	}

	public void setPayType(int payType) {
		this.payType = payType;
	}

	public int getIsCancel() {
		return isCancel;
	}

	public void setIsCancel(int isCancel) {
		this.isCancel = isCancel;
	}

	public long getOrderNumberDays() {
		return orderNumberDays;
	}

	public void setOrderNumberDays(long orderNumberDays) {
		this.orderNumberDays = orderNumberDays;
	}

	public int getCancelType() {
		return cancelType;
	}

	public void setCancelType(int cancelType) {
		this.cancelType = cancelType;
	}

	public int getOrdersState() {
		return ordersState;
	}

	public void setOrdersState(int ordersState) {
		this.ordersState = ordersState;
	}

	public String getTimeDay() {
		return timeDay;
	}

	public void setTimeDay(String timeDay) {
		this.timeDay = timeDay;
	}

	public String getBossAvatar() {
		return bossAvatar;
	}

	public void setBossAvatar(String bossAvatar) {
		this.bossAvatar = bossAvatar;
	}

	public String getBossNickname() {
		return bossNickname;
	}

	public void setBossNickname(String bossNickname) {
		this.bossNickname = bossNickname;
	}

	public int getBossOrdersState() {
		return bossOrdersState;
	}

	public void setBossOrdersState(int bossOrdersState) {
		this.bossOrdersState = bossOrdersState;
	}

	public int getSecretaryOrdersState() {
		return secretaryOrdersState;
	}

	public void setSecretaryOrdersState(int secretaryOrdersState) {
		this.secretaryOrdersState = secretaryOrdersState;
	}


	
	
}
